#include "RazoukRampalLerenduFSM_complete_machine.h"

using namespace FSM;

FSM_complete_machine::FSM_complete_machine(const FSM_determinist_machine &machine) : FSM_determinist_machine(machine)
{
	FSM_State* trashState = new FSM_State;
	trashState->name = "TrashState";
	_states.push_back(trashState);
	list<FSM_State*>::iterator it1;
	vector<char>::iterator it2;
	list<FSM_transition*>::iterator it3;
	bool transitionFound;

	for(it1 = _states.begin(); it1 != _states.end(); ++it1)
	{
		for(it2 = _alphabet.begin(); it2 != _alphabet.end(); ++it2)
		{
			transitionFound = false;
			for(it3 = (*it1)->transitions.begin(); it3 != (*it1)->transitions.end(); ++it3)
			{
				if((*it3)->caractere == *it2)
				{
					transitionFound = true;
					break;
				}				
			}

			// If transition not found, create it to trashState
			if(!transitionFound)
			{
				FSM_transition *tmp = new FSM_transition;
				tmp->caractere = (*it2);
				tmp->nextState = trashState;
				(*it1)->transitions.push_back(tmp);
			}

		}
	}

}


FSM_complete_machine::~FSM_complete_machine(void)
{
}
